<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>02_v-bind动态绑定class(一)</title>

    <style>
      .active {
        color: blueviolet;
      }
      .line {
        background-color: coral;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <h3 class="active">{{message}}</h3>
      <h4 :class="MYactive">{{message}}</h4>

      <!-- <h2 v-bind:class="{key1:value1, key2:value2}">{{message}}</h2> -->
      <!-- <h2 v-bind:class="{类名1:true, 类名2:boolean}">{{message}}</h2> //当某一个Boolean为true时类赋给这个class -->
      <h2 v-bind:class="{active:isActive, line:isLine}">{{message}}</h2>
      <button v-on:click="btnClick">点击按钮</button>
    </div>
    <script src="../vue.js"></script>

    <script>
      const app = new Vue({
        el: "#app", //用于挂载要管理的元素
        data: {
          message: "hello",
          MYactive: "active",
          isActive: true,
          isLine: true,
        },
        methods: {
          btnClick: function () {
            this.isActive = !this.isActive;
          },
        },
      });
    </script>
  </body>
</html>
